package service;

import java.util.Iterator;

import models.Adpo;
import models.Advert;

public class AdsService {

	public static String get(String code,int i){
		String str = "";
		Adpo  a = AdpoService.findByCode(code, i);
		if(a == null)return "";
			if(a.adverts == null)return "";
			if(a.adverts.size() <= 0)return "";
			Iterator iter = a.adverts.iterator();
			int j = 0;
			while (iter.hasNext() && j < i) {
				Advert adv = (Advert) iter.next();
				str += "<div style='width:"+a.adpWid+"px;height:"+a.adpHig+"px;margin:0 auto 5px;overflow:hidden'>";
					str += "<a href='"+adv.advHref+"'>"+adv.advDet+"</a>";
				str +="</div>";
				j++;
			}
		return str;
	}
}
